Option Strict Off
Option Explicit On
Module Module12
    Private Declare Function ECF_UltimoItemVendido Lib "CONVECF.DLL" (ByVal UltimoItem As String) As Integer
    Private Declare Function ECF_SubTotal Lib "CONVECF.DLL" (ByVal SubTotal As String) As Integer
    Private Declare Function ECF_SubTotalComprovanteNaoFiscalMFD Lib "CONVECF.DLL" (ByVal SubTotalCNF As String) As Integer
    Private Declare Function ECF_ValorPagoUltimoCupom Lib "CONVECF.DLL" (ByVal Valor As String) As Integer
    Private Declare Function ECF_NumeroCupom Lib "CONVECF.DLL" (ByVal NumCupom As String) As Integer
    Private Declare Function ECF_VerificaFormasPagamentoMFD Lib "CONVECF.DLL" (ByVal FormasPag As String) As Integer


    Function UltimoItemVendido() As Object
        Dim retorno As Object
        Dim item As String

        item = Space(4)
        retorno = ECF_UltimoItemVendido(item)


        MsgBox(" 'Último Item Vendido' " & vbCrLf & "Status: " & retorno)
        Form1.List1.Items.Add("Último Item Vendido: " & item)
    End Function

    Function SubTotalCF() As Object
        Dim retorno As Object
        Dim SubTot As String

        SubTot = Space(14)

        retorno = ECF_SubTotal(SubTot)


        MsgBox(" 'Subtotal do Cupom Fiscal' " & vbCrLf & "Status: " & retorno)
        Form1.List1.Items.Add("Subtotal: " & SubTot)
    End Function

    Function SubTotalCNF() As Object
        Dim retorno As Object
        Dim SubTotCNF As String

        SubTotCNF = Space(14)

        retorno = ECF_SubTotalComprovanteNaoFiscalMFD(SubTotCNF)


        MsgBox(" 'Subtotal do Comprovante' " & vbCrLf & "Status: " & retorno)
        Form1.List1.Items.Add("Subtotal Comprovante: " & SubTotCNF)
    End Function

    Function ValorPagoUltimoCupom() As Object
        Dim retorno As Object
        Dim Val_Renamed As String

        Val_Renamed = Space(14)

        retorno = ECF_ValorPagoUltimoCupom(Val_Renamed)


        MsgBox(" 'Valor Pago no Último Cupom' " & vbCrLf & "Status: " & retorno)
        Form1.List1.Items.Add("Valor Pago: " & Val_Renamed)
    End Function

    Function NumeroCupom() As Object
        Dim retorno As Object
        Dim NCupom As String

        NCupom = Space(6)

        retorno = ECF_NumeroCupom(NCupom)


        MsgBox(" 'Nº do Cupom' " & vbCrLf & "Status: " & retorno)
        Form1.List1.Items.Add("Nº do Cupom: " & NCupom)
    End Function

    Function VerificaFormasPagamento() As Object
        Dim retorno As Object
        Dim ForPag, temp As String
        Dim I, pos As Integer

        ForPag = Space(919)


        retorno = ECF_VerificaFormasPagamentoMFD(ForPag)


        MsgBox(" 'Verifica Forma de Pagamento' " & vbCrLf & "Status: " & retorno)
        pos = 1
        I = 1
        Form1.List1.Items.Add("Formas de Pagamento:")
        Do While pos > 0

            pos = InStr(1, ForPag, ",")

            If pos > 0 Then
                temp = Left(ForPag, pos - 1)
                ForPag = Right(ForPag, Len(ForPag) - pos)
                Form1.List1.Items.Add("    " & Right("0" & CStr(I), 2) & ": " & temp)
                I = I + 1
            End If
        Loop

    End Function
End Module